# utils/validator.py
from datetime import datetime

def validate_required(fields):
    for field in fields:
        if not field.value.strip():
            field.error_text = "该字段必填"
            field.update()
            return False
    return True

def validate_date(date_str):
    try:
        datetime.strptime(date_str, "%Y-%m-%d")
        return True
    except ValueError:
        return False
